package com.shqcjd.preinstallmobile.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shqcjd.preinstallmobile.R;
import com.shqcjd.preinstallmobile.model.pojo.DefectManageBean;

import java.util.List;

public class EqumentInfoDefectAdapter extends BaseAdapter {

    private List<DefectManageBean.ListBean> mList;
    private LayoutInflater inflater;

    public EqumentInfoDefectAdapter(List<DefectManageBean.ListBean> mList, Context context) {
        this.mList = mList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : (mList.size()>2?2:mList.size());
    }

    @Override
    public Object getItem(int position) {
        return null;
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view = inflater.inflate(R.layout.item_equipment_info_defect, null);
        TextView tv_item_equipment_defect_name = view.findViewById(R.id.tv_item_equipment_defect_name);
        TextView tv_item_equipment_defect_state = view.findViewById(R.id.tv_item_equipment_defect_state);
        TextView tv_item_equipment_defect_type = view.findViewById(R.id.tv_item_equipment_defect_type);
        TextView tv_item_equipment_defect_info = view.findViewById(R.id.tv_item_equipment_defect_info);
        TextView tv_item_equipment_defect_end = view.findViewById(R.id.tv_item_equipment_defect_end);
        TextView tv_item_equipment_defect_start = view.findViewById(R.id.tv_item_equipment_defect_start);
        tv_item_equipment_defect_name.setText(mList.get(position).equipmentName);
        tv_item_equipment_defect_state.setText("("+mList.get(position).state+")");
        tv_item_equipment_defect_type.setText(mList.get(position).equipmentTypeName);
        tv_item_equipment_defect_info.setText("● 缺陷说明: "+mList.get(position).description);
        tv_item_equipment_defect_end.setText("解决时间: "+mList.get(position).resolveTime);
        tv_item_equipment_defect_start.setText("发现时间: "+mList.get(position).discoveryTime);
        return view;
    }

}